#!/usr/bin/env python

import sys,pickle,os,glob,traceback,sqlite3,scipy,cPickle
import matplotlib
if "DISPLAY" not in os.environ: matplotlib.use("AGG")
else: matplotlib.use("GTK")
from optparse import OptionParser
import pygtk
pygtk.require("2.0") 
import gobject,gtk,gtk.glade
from pylab import *
import ocrolib
from ocrolib import docproc,utils,gatedmodel

parser = OptionParser(usage="""
%prog -o gated.model input1.model input2.model ...

Combine classifiers into a gated model.  Classifiers with a corresponding .info
file are gated, while other classifiers are used unconditionally.
""")
parser.add_option("-c","--cutoff",help="cutoff",type=float,default=0.75)
parser.add_option("-o","--output",help="ouptut file",default="gated.cmodel")
(options,args) = parser.parse_args()

model = gatedmodel.GatedModel()
gatedmodel.load_gatedmodel(model,args,cutoff=options.cutoff)
with open(options.output,"wb") as stream:
    cPickle.dump(model,stream)
